package com.item.model;

import com.item.model.entity.WxUser;
import com.item.model.util.RedisUtil;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

import javax.sql.DataSource;
import java.util.concurrent.TimeUnit;

/**
 * redisUtil测试
 * @author zhang-rongyao
 * @version V1.0
 * @Package com.item
 * @date 2021/7/21 8:57
 */
@SpringBootTest
public class BBB {

    @Autowired
    DataSource dataSource;

    @Test
    public void aa() throws Exception {

        System.out.println(dataSource.getClass());
        System.out.println(dataSource.getConnection());
    }

    @Autowired
    RedisUtil redisUtil;

    @Test
    public void bb() throws Exception {

        Object aafdas = redisUtil.get("aafdas");
        if (!(aafdas == null)) {
            System.out.println(String.valueOf(aafdas));
        }

        redisUtil.set("aaa", "fdsafasd");
        redisUtil.setEx("fdasfdasfsda", "123456478", 10000, TimeUnit.MILLISECONDS);
        System.out.println(redisUtil.get("fdasfdasfsda"));

    }

    @Test
    public void cc() throws Exception {

        WxUser wxUser = new WxUser();
        wxUser.setAge(15);
        wxUser.setName("李四");
        wxUser.setEmail("123456@163.com");
        wxUser.setDeleted(1);
        redisUtil.setEx("fdsafas", wxUser, 10000, TimeUnit.MILLISECONDS);
        System.out.println(redisUtil.get("fdsafas"));

    }
}
